from concurrent.futures import ThreadPoolExecutor, as_completed


def some_function(arg):
    return arg * 2


with ThreadPoolExecutor() as executor:
    tasks = [executor.submit(some_function, i) for i in range(10)]
    for future in as_completed(tasks):
        result = future.result()
        print(result)

"""
as_completed 和 map 方法：as_completed 方法可以按照任务完成的顺序迭代返回结果，而 map 方法可以提交一个可迭代的任务列表，并按照它们在可迭代对象中的顺序返回结果。
"""